package com.gec.system.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gec.model.system.ITripLoginLog;
import com.gec.model.vo.ITripLoginLogQueryVo;
import com.gec.system.common.Result;
import com.gec.system.service.ITripLoginLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 系统访问记录 前端控制器
 * </p>
 *
 * @author chenzhiling
 * @since 2024-01-20
 */
@RestController
@RequestMapping("/system/itrLoginLog")
@Api(tags = "登录日志管理")
@CrossOrigin
public class ITripLoginLogController {
    @Autowired
    private ITripLoginLogService iTripLoginLogService;

    @ApiOperation(value = "获取分页列表")
    @GetMapping("{page}/{limit}")
    public Result QueryLoginLog(
            @PathVariable Long page,
            @PathVariable Long limit,
            ITripLoginLogQueryVo iTripLoginLogQueryVo) {

        IPage<ITripLoginLog> iPage = iTripLoginLogService.selectPage(page, limit, iTripLoginLogQueryVo);
        return Result.ok(iPage);
    }

    @ApiOperation(value = "获取")
    @GetMapping("get/{id}")
    public Result get(@PathVariable Long id) {
        ITripLoginLog iTripLoginLog = iTripLoginLogService.getById(id);
        return Result.ok(iTripLoginLog);
    }

    @ApiOperation(value = "通过id删除")
    @DeleteMapping("removeById/{id}")
    public Result remove(@PathVariable Long id) {
        iTripLoginLogService.removeById(id);
        return Result.ok();
    }

    // 批量删除
    @ApiOperation("批量删除")
    @DeleteMapping("/removeByIds")
    public Result removeByIds(@RequestBody List<Long> ids) {
        boolean b = this.iTripLoginLogService.removeByIds(ids);
        if (b) {
            return Result.ok();
        } else {
            return Result.fail();
        }
    }
}

